package com.devbobcorn.nekoration.sounds.music;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import com.devbobcorn.nekoration.utils.ZLibHelper;

public class LyricsDecoder {
    private static final char[] CODE = { '@', 'G', 'a', 'w', '^', '2', 't', 'G', 'Q', '6', '1', '-', 'Î', 'Ò', 'n', 'i' };

    public static String decode(File source) throws IOException {
        byte[] zipByte = new byte[(int) source.length() - 4];
        FileInputStream stream = new FileInputStream(source);
        byte[] top = new byte[4];
        stream.read(top);
        stream.read(zipByte);
        int len = zipByte.length;
        for (int k = 0; k < len; k++) {
            int l = k % 16;
            int tmp67_65 = k;
            byte[] tmp67_64 = zipByte;
            tmp67_64[tmp67_65] = (byte) (tmp67_64[tmp67_65] ^ CODE[l]);
        }
        String decoded = new String(ZLibHelper.decompress(zipByte), "utf-8");
        stream.close();
        return decoded;
    }
}
